<?php
class SessionComponent{
	var $controller;
	function __construct($controller){
		if (!isset($_SESSION)) {
			session_cache_limiter ("must-revalidate");
			session_start();
			header ('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
			return true;
		} else {
			session_start();
			return true;
		}
	}
	function initialize($controller){
		$controller->Session=$this;
		$this->controller=$controller;
	}
	function startup(){

	}
	function read($str){
		$path=preg_split('/[\.]/',$str);
		$data=$_SESSION;
		foreach($path as $key => $value){
			if(isset($data[$value])){
				$data=$data[$value];
			}else{
				return null;
			}
		}
		return $data;
	}
	function write($str, $w_data){
		$path=preg_split('/[\.]/',$str);
		$data=&$_SESSION;
		foreach($path as $key => $value){
			if(!isset($data[$value])){
				$data[$value]=Array();
			}
			if($key<count($path)-1){
				$data=&$data[$value];
			}else{
				$data[$value]=$w_data;
			}
		}
		return true;
	}
}